package cn.com.fstar.demo.service;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.com.fstar.framework.base.dao.BaseDaoI;
import cn.com.fstar.core.model.TcontentAttachment;

/**
 * 描述: 标准的附件管理
 * 
 * @author 
 * @date 2016年4月18日 下午5:00:05
 */
@Service
public class AttachmentService {
    @Autowired
    private BaseDaoI<TcontentAttachment> attachStandardDao;

    /**
     * 描述: 根据附件的id删除附加
     * 
     * @param id
     * void
     */
    public void deleteAttachById(String id) {
        TcontentAttachment tattachStandard = getAttachById(id);
        if (tattachStandard != null) {
            attachStandardDao.delete(tattachStandard);
        }
     
    }

    /**
     * 
     * 描述: 根据id查询Tmodel
     * 
     * @param id
     * @return TattachStandard
     */
    private TcontentAttachment getAttachById(String id) {
        return attachStandardDao.get(TcontentAttachment.class, id);

    }

    public TcontentAttachment get(String id) {
        TcontentAttachment attach = getAttachById(id);
        TcontentAttachment attachStandard = new TcontentAttachment();
        if (attach != null) {
            BeanUtils.copyProperties(attach, attachStandard);
        }
        return attachStandard;
    }

}
